174A - Problem About Equation - CodeForces Solution


math *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define debug_ok cout<<"debug_ok"<<endl;
#define optimize ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define vtr vector<int>
#define pb push_back
const int INF=1e9+7;
const int N=1e7+7;
const int MOD=1e9+7;
void solve()
{
	double n,b;
	cin>>n>>b;
	std::vector<int> v;
	double pre_sum = 0;
	for(int i = 0 ;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
		pre_sum+=x;
	}
	double total = pre_sum + b;
	double per_person = total/n;
	bool flag = true;
	for(int i = 0;i<n;i++)
	{
		if(v[i]>per_person)flag = false;
	}
	
		if(flag)
		{	for(int i = 0;i<n;i++){
			double k = per_person-v[i];
		    printf("%.7f\n",k);
		}
	}
	else cout<<-1<<endl;
}
signed main()
	{
		solve();
	}


Comments

Submit
0 Comments
More Questions

Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble